const express = require('express')
const router = express.Router()

const { getRestaurantCount, getRestaurantList, searchRestaurant, toggleHotRestaurant, deleteRestaurant, publishRestaurantData } = require('../../controller/apis/RestaurantController')
const { createUploadMiddleware } = require('../../middleware/UploadImageMiddleware')

// 导入JWT拦截中间件
const checkTokenMiddleware = require('../../middleware/checkTokenMiddleware')
// 导入分页中间件
const paginationMiddleware = require('../../middleware/paginationMiddleware');

// 获取餐厅总数
router.get('/restaurant/count', checkTokenMiddleware, getRestaurantCount)

// 获取餐厅列表信息
router.get('/restaurant/list', paginationMiddleware, checkTokenMiddleware, getRestaurantList)

// 餐厅列表搜索功能
router.get('/restaurant/search', checkTokenMiddleware, searchRestaurant)

// 酒店热门状态切换
router.patch('/restaurant/hot/toggle/:id', checkTokenMiddleware, toggleHotRestaurant)

// 删除餐厅
router.delete('/restaurant/del/:id', checkTokenMiddleware, deleteRestaurant)

// 上传餐厅图片
const uploadPostImages = createUploadMiddleware('Restaurant')
router.post('/restaurant/upload', checkTokenMiddleware, uploadPostImages)

// 发布餐厅
router.post('/restaurant/publish', checkTokenMiddleware, publishRestaurantData)

module.exports = router